package com.unitechs.trap.write.webapi.service.impl;

import com.unitechs.trap.common.pojo.trap.entity.TrapType;
import com.unitechs.trap.excel.service.ITrapTypeExcelService;
import com.unitechs.trap.write.service.ITrapTypeService;
import com.unitechs.trap.write.webapi.mapper.TrapTypeMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@DubboService
@Slf4j
@Service

public class TrapTypeServiceImpl implements ITrapTypeService {

    @Autowired
    private TrapTypeMapper trapTypeMapper;
    @DubboReference(timeout = 1*1024*1024*1024)
    private ITrapTypeExcelService trapTypeExcelService;


    @Override
    public int insertTrapTypes() {
        List<TrapType> trapTypes=trapTypeExcelService.listTrapType();
        if (trapTypes==null||trapTypes.isEmpty()){
            return 0;
        }
        int i = trapTypeMapper.insertTrapTypes(trapTypes);
        return i;
    }
}
